package oop.core.entity;

import java.util.List;

import oop.core.ai.AI;
import oop.core.item.Equipment;
import oop.core.item.Inventory;
import oop.core.map.Location;
import oop.core.map.MovementType;

/**
 *
 */
public class NPC extends Entity {
	private AI AI;
	private String[] dialogue; // array of length 3
	public int favoribility; // int from 0 to 10
	private boolean isHostile;
	private int viewRange;
	
	public NPC(AI AI, String[] dialogue, boolean isHostile, int viewRange, String image, String name, int direction, Location loc, boolean isVisible, Equipment equipment, Inventory inventory, List<MovementType> movementType, DerivedStats derivedStats, int givenEXP){
		super(image, name, direction, loc, isVisible, equipment, inventory, movementType, derivedStats, givenEXP);
		this.AI = AI;
		this.dialogue = dialogue;
		this.isHostile = isHostile;
		this.viewRange = viewRange;
		this.favoribility = 0;
	}

	/**
	 * Fuck Navi.
	 */
	public void listen()
	{
		System.out.println("Hey, listen!");
	}
	
	public long getMovementSpeed(){
		return derStats.getMovement();
	}
	
	/**
	 * Returns a dialogue based on how much the entity likes do.
	 * @return
	 */
	public String talk(){
		int fav = 0;
		if(favoribility >= 1 && favoribility <= 5){
			fav = 1;
		}
		else
			fav = 2;
		return dialogue[fav];
	}

	public AI getAI() {
		return AI;
	}

	public void setAI(AI aI) {
		AI = aI;
	}

	public String[] getDialogue() {
		return dialogue;
	}

	public void setDialogue(String[] dialogue) {
		this.dialogue = dialogue;
	}

	public boolean isHostile() {
		return isHostile;
	}

	/**
	 * Changes if an NPC is hostile.
	 * @param isHostile
	 */
	public void setHostile(boolean isHostile) {
		if(isHostile)
			this.favoribility = 0;
		else 
			this.favoribility = Math.max(this.favoribility, 1);
		this.isHostile = isHostile;
	}
	
	public int getViewRange(){
		return viewRange;
	}
	public void setRange(int viewRange){
		this.viewRange = viewRange;
	}

	@Override
	public String getImageID() {
		return name;
	}

	public int getFavoribility() {
		return favoribility;
	}

	public void setFavoribility(int favoribility) {
		if(favoribility == 0)
			setHostile(true);
		else
			setHostile(false);
		this.favoribility = favoribility;
	}
	
	public void modifyFavoribility(int bonus){
		setFavoribility(favoribility + bonus);
	}

	public void setViewRange(int viewRange) {
		this.viewRange = viewRange;
	}
}
